class Machine < ActiveRecord::Base
  belongs_to :salle  #Permet de créer les associations multiples entre les objets

  has_many :incidents, :foreign_key => "machineid" #Permet de créer les associations entre les objets
 
  validates_presence_of :nommachine ,:ipmachine ,:espacedisquet,
        :memoiretotale ,:os , :addmac
   validates_numericality_of   :memoiretotale ,:with => /^\d+??(?:\.\d{0,2})?$/
      #:message => " doit être entier ou decimal...!"
        #:only_integer => true, :message => "can only be between 21 and 30."
   validates_numericality_of   :espacedisquet ,:with => /^\d+??(?:\.\d{0,2})?$/
    #    :message => " doit être entier ou decimal...!"
   validates_format_of :ipmachine, :with =>/^(25[0-4]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-4]|2[0-4]\d|[0-1]?\d?\d)){3}$/
   validates_format_of :addmac, :with=>/^([A-F]|[a-f]|[0-9])*/
   validates_uniqueness_of :ipmachine
   validates_uniqueness_of :addmac

end
